
// 分页生成
function getIndexButton(num, pageIndex) {	//（总数，当前index）
  // console.log(num)
  if (pageIndex == 1) {
    var html = '<span class="disable">上一页</span>'
    if (num <= 1) {
      html += '<span class="selected">1</span>'
      html += '<span class="disable">下一页</span>'
    } else if (num <= 5) {
      html += '<span class="selected">1</span>'
      for (var i = 2; i <= num; i++) {
        html += '<span class="num">' + i + '</span>'
      }
      html += '<span class="next">下一页</span>'

    } else if (num > 5) {
      html += '<span class="selected">1</span>'
      for (var i = 2; i <= 5; i++) {
        html += '<span class="num">' + i + '</span>'
      }
      html += '<span class="next" style="border-color:#414a60;">...</span>'
      html += '<span class="next">下一页</span>'
    }
    // console.log($('.wdmxBox .pageNav'))
    $('.wdmxBox .pageNav').empty()
    $('.wdmxBox .pageNav').prepend(html)
    // console.log(html)

  } else {
    var html = '<span class="before">上一页</span><span class="before">' + (pageIndex - 1) + '</span><span class="selected">' + pageIndex + '</span>'
    var newNum = num - pageIndex
    // console.log('newNum',newNum)
    if (newNum == 0) {
      html += '<span class="disable">下一页</span>'
    } else if (newNum >= 1 && newNum <= 3) {
      for (var i = 1; i <= newNum; i++) {
        html += '<span class="num">' + (pageIndex - 0 + i) + '</span>'
        // console.log(i,pageIndex)
      }
      html += '<span class="next">下一页</span>'
    } else if (newNum > 3) {
      for (var i = 1; i <= 3; i++) {
        html += '<span class="num">' + (pageIndex - 0 + i) + '</span>'
        // console.log(i,pageIndex-0+i)
      }
      html += '<span class="next" style="border-color:#414a60;">...</span>'
      html += '<span class="next">下一页</span>'
    }
    $('.wdmxBox .pageNav').empty()
    $('.wdmxBox .pageNav').prepend(html)
  }
  $('.wdmxBox .pageNav .num').click(function () {
    console.log(897, $(this).text())
    getTopMx($(this).text())
  })
  $('.wdmxBox .pageNav .next').click(function () {
    // console.log(8979)
    getTopMx(pageIndex + 1)
  })
  $('.wdmxBox .pageNav .before').click(function () {
    // console.log(8979)
    getTopMx(pageIndex - 1)
  })

}
